#include<iostream>
#include<vector>
using namespace std;
vector<int>v;
int num[100000][2];
int l;
int fun(int b,int e){
    int day=0,m=v[b];
    if(b<e){
        for(int i=b;i<e;i++){
            if(m<=v[i]&&v[i]+l>v[i+1]){
                day++;
                m=v[i]+l;
            }else if(m<v[i]&&v[i]+l<v[i+1]){
                day+=2;
                m=v[i+1]+l;
            }
            // cout<<"m="<<m<<"\tday="<<day<<"\tv[i]="<<v[i]<<endl;
        }
    }else{
        for(int i=b;i>e;i--){
            if(m>=v[i]&&v[i]-l<v[i-1]){
                m=v[i]-l;
                day++;
            }else if(m>v[i]&&v[i]-l>v[i-1]){
                day+=2;
                m=v[i-1]-l;
            }
            // cout<<"m="<<m<<"\tday="<<day<<"\tv[i]="<<v[i]<<endl;
        }
    }
    return day;
}
int main(){
    int n,k,q,a,b;cin>>n;
    for(int i=0;i<n;i++){
        cin>>k;
        v.push_back(k);
    }cin>>l>>q;
    for(int i=0;i<q;i++)
        cin>>num[i][0]>>num[i][1];
    for(int i=0;i<q;i++)
        cout<<fun(num[i][0]-1,num[i][1]-1)<<endl;
    return 0;
}